﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;

namespace mp.message.util
{
    public class WriteLog
    {
        public static void PrintLog(string str)
        {
            StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath("weixin.log"), true);
            sw.WriteLine(str);
            sw.Flush();
            sw.Close();
        }
    }

        /// <summary>
    /// 得到从微信POST过来的XML字符串信息
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    //public string GetPostXmlString(HttpContext context)
    //{
    //    string postStr = "";
    //    if (context.Request.HttpMethod.ToLower() == "post")//当普通微信用户向公众账号发消息时，微信服务器将POST该消息到填写的URL上
    //    {
    //        System.IO.Stream s = context.Request.InputStream;
    //        byte[] b = new byte[s.Length];
    //        s.Read(b, 0, (int)s.Length);
    //        postStr = System.Text.Encoding.UTF8.GetString(b);//得到微信POST过来的XML格式数据。
    //        if (string.IsNullOrEmpty(postStr) == false)
    //        {
    //            return postStr;   
    //        }
    //    }
    //    return postStr;
    //}
}
